<?php
require_once $ubi['SERVER']['SERVER_ROOT'] . '/dao/dbConnection.php';
require_once $ubi['SERVER']['SERVER_ROOT'] . '/model/privacy_email.php';

class PrivacyEmailDao {
	private $_db;	
	
	public function __construct() {
		$this->_db = new DbConnection();
		$this->_db->getConnection();
	}
	
	public function addPrivacyEmail($privacy_email) {		
     	$query = sprintf("INSERT INTO privacy_email(UserId, PrivacyId) VALUES ('%u', '%u')", $privacy_email->getUserID(), $privacy_email->getPrivacyID());

     	$result = $this->_db->executeQuery($query);
		
		if (!$result) {
		    echo 'Could not run query: ' . ' ' . $query . ' ' . mysql_error();
		    return 0;
		}
		return;
	}
	
	public function removePrivacyEmail($privacy_email) {		
     	$query = sprintf("DELETE FROM privacy_email WHERE UserId = '%u' AND PrivacyId = '%u'", $privacy_email->getUserID(), $privacy_email->getPrivacyID());

     	$result = $this->_db->executeQuery($query);
		
		if (!$result) {
		    echo 'Could not run query: ' . ' ' . $query . ' ' . mysql_error();
		    return 0;
		}
		return;
	}	
}
?>